# 7）楼层数量（柱状图）【横坐标为楼层，纵坐标为数量】

import pandas as pd
import pyecharts.options as opts
from pyecharts.charts import Bar

df = pd.read_excel('data_clean.xlsx')


locations = [location for location in df['true_floor'].value_counts().items()]

x_data =[]
y_data = []
for i in range(len(locations)):
    x_data.append(str(locations[i][0]) + "层")
    y_data.append(locations[i][1])


c = (
    Bar()
    .add_xaxis(x_data)
    .add_yaxis("数量", y_data)
    .set_global_opts(
        xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)),
        title_opts=opts.TitleOpts(title="Bar-旋转X轴标签", subtitle="解决标签名字过长的问题"),
    )
    .render("bar_rotate_xaxis_label.html")
)